package com.zhn.evsi.config;

import com.github.xiaoymin.swaggerbootstrapui.annotations.EnableSwaggerBootstrapUI;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * swagger
 * */
@Configuration
@EnableSwagger2
@EnableSwaggerBootstrapUI
public class SwaggerConfig {

    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zhn.evsi.controller"))
                .paths(PathSelectors.any())
                .build()
                .groupName("开发");
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("EVE 数据对接接口")
                .description("EVE 数据可视化")
                .contact(new Contact("张颢瀚", "http://localhost:8100", "1085155177@qq.com"))
                .version("0.0.1 dev")
                .build();
    }
}
